package com.gccloud.tgyfirst.service.friend.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gccloud.starter.common.dto.SearchDTO;
import com.gccloud.starter.mybatis.page.PageVO;
import com.gccloud.starter.mybatis.utils.QueryWrapperUtils;
import com.gccloud.tgyfirst.friend.entity.FriendEntity;
import com.gccloud.tgyfirst.service.friend.dao.FriendDao;
import com.gccloud.tgyfirst.service.friend.service.IFriendService;
import org.springframework.stereotype.Service;

@Service
public class FriendService extends ServiceImpl<FriendDao, FriendEntity> implements IFriendService {
    @Override
    public PageVO<FriendEntity> getPage(SearchDTO searchDTO) {
        LambdaQueryWrapper<FriendEntity> queryWrapper = QueryWrapperUtils.wrapperLike
                (new LambdaQueryWrapper<>(), searchDTO.getSearchKey(), FriendEntity::getName);
        return pageWithDp(searchDTO,queryWrapper);
    }

    @Override
    public void add(FriendEntity friendEntity) {
        this.save(friendEntity);
    }

    @Override
    public void upd(FriendEntity friendEntity) {
        updateByIdWithDp(friendEntity);
    }


    @Override
    public void del(String Id) {
        deleteByIdWithDp(Id);
    }
}
